<template>
	<view class="container">
		<view class="container-info">
			<view class="container-info-box">
				喂食时间：
				<span>{{form.eventTime}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				就餐类型：
				<span>{{getValue(radioList,form.diet)}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				食量：
				<span>{{getValue(appetiteList,form.quantity)}}</span>
			</view>
		</view>
		<view class="container-info">
			<view class="container-info-box">
				照片：
				<view style="margin-top: 20rpx;">
					<LmageListView 
							:resourceUrls="form.medias | resourceUrlFilter" />
					</view>
				</view>
		</view>
		<view class="container-info">
			<view class="container-info-box" style="display: flex;">
				<view class="remark-lable">备注：</view>
				<textarea  v-model="form.food" rows="3" placeholder="请输入备注"/>
			</view>
		</view>

	</view>
</template>

<script>
	import {
		getRecordFoodInfo
	} from './api/index.js'
	import recordMixin from './mixins/info.js'
	import LmageListView from '@/components/image-list-view.vue'
	import {
		formatDateByTimestamp
	} from '@/utils/utils.js'
	export default {
		mixins: [recordMixin],
		components: {
			// MultiMediaView,
			LmageListView
		},
		data() {
			return {
				form: {
					eventTime: formatDateByTimestamp(Date.now(), 'yyyy/mm/dd hh:MM:ss'),
					temperature: 36.5,
					emotion: 3,
					bodyState: 3,
					remark: '',
				},
				radioList: [{
						name: '早餐',
						value: '1',
					},
					{
						name: '上午点心',
						value: '2',
					},
					{
						name: '午餐',
						value: '3',
					},
					{
						name: '下午点心',
						value: '4',
					},
					{
						name: '晚餐',
						value: '5',
					},
					{
						name: '随餐',
						value: '0',
					}
				],

				appetiteList: [{
						name: '正常',
						value: '0',
					},
					{
						name: '量多',
						value: '2',
					},
					{
						name: '量少',
						value: '1',
					}
				],
			}
		},
		filters: {
			resourceUrlFilter (value) {
				if (!value) {
					return []
				}
				return value.split('|');
			}
		},
		methods: {
			getValue(list,value) {
				return list.find(item => item.value * 1 === value * 1)?.name
			},
			getRecord() {
				console.log(this.recordId)
				if (this.$u.test.isEmpty(this.recordId)) {
					return;
				}
				uni.showLoading({})
				const params = {
					id: this.recordId,
					childId: this.defaultChildren.id
				}
					getRecordFoodInfo(params).then(res => {
						console.log(res)
						uni.hideLoading()
						const { food, diet, quantity,medias} = res.data; 
						const eventTime = formatDateByTimestamp(res.data.eventTime, 'yyyy/mm/dd hh:MM:ss')
						const form = {
							eventTime,
							food,
							diet,
							quantity,
							medias
						};
							
						this.form = form
					})		

			
			},
		}
	}
</script>

<style lang="scss" scoped>


</style>

